// ai-agent.cpp : Defines the entry point for the console application.
//
#define _DEBUG

#ifdef _DEBUG
#ifndef DBG_NEW
#define DBG_NEW new ( _NORMAL_BLOCK , __FILE__ , __LINE__ )
#define new DBG_NEW
#endif
#endif  // _DEBUG


#define _CRTDBG_MAP_ALLOC
#include <stdlib.h>
#include <crtdbg.h>

#include "stdafx.h"
#include <iostream>
#include <Windows.h>

#include "AI_Actor.h"

#include "debug.h"


int _tmain(int argc, _TCHAR* argv[])
{
	std::cout << "Test";

	WorldData::WorldData(250, 250, 20.0f, (0 - (250 / 20)), (0 - (250 / 20)));

	AI_Actor* actor = new AI_Actor(CharacterTypes::wimp);

	AI_Actor** actors = new AI_Actor*[20];
	for (int i = 0; i < 20; i++)
	{
		actors[i] = new AI_Actor(CharacterTypes::wimp);
	}


	//Event* e1 = new enemyEntersRadius_e(1.0f, 1.0f, 0.0f);
	//Event* e2 = new enemyEntersRadius_e(1.0f, 1.0f, 0.0f);
	//Event* e3 = new enemyEntersRadius_e(1.0f, 1.0f, 0.0f);
	//Event* e4 = new shootsAt_e(1.0f, 1.0f, 0.0f);


	//actor->eventTriggered(e1);
	//actor->eventTriggered(e2);
	//actor->eventTriggered(e3);
	//actor->eventTriggered(e4);

//	actor->eventTriggered(new enemyEntersRadius_e(1.0f, 1.0f, 0.0f));
//	actor->eventTriggered(new enemyEntersRadius_e(1.0f, 1.0f, 0.0f));
//	actor->eventTriggered(new enemyEntersRadius_e(1.0f, 1.0f, 0.0f));
//	actor->eventTriggered(new Event());

	
	ActionList* actions = NULL;

	int counter = 0;

	while (true)
	{
		for (int i = 0; i < 20; i++)
		{
			actors[i]->eventTriggered(new shootsAt_e(1.0f, 1.0f, 0.0f));
		}

		for (int i = 0; i < 20; i++)
		{
			actions = actors[i]->updateBehaviour(0.1f);
		}



		//Event* temp = new enemyEntersRadius_e(1.0f, 1.0f, 0.0f);
		//actor->eventTriggered(temp);
		//actor->updateBehaviour(0.2f);

		WorldData::tick(0.2f);
		Sleep(1);

		counter++;

		/*if (counter == 15)
			actor->eventTriggered(new shootsAt_e(1.0f, 1.0f, 0.0f));*/

		delete actions;

		if (counter > 5000)
			break;
	}
	

	//Cleanup
	delete actor;

	for (int i = 0; i < 20; i++)
	{
		delete actors[i];
	}
	delete actors;


	_CrtDumpMemoryLeaks();


	int dummy;
	std::cin >> dummy;



	return 0;
}
